--立鸟陨翼
local liniaoyunyi = fk.CreateSkill {
    name = "mcdh_liniaoyunyi",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

liniaoyunyi:addEffect(fk.TargetConfirmed,{
    can_trigger = function(self, event, target, player, data)
            return player:hasSkill(self) and target == player and #player:getCardIds("he") > 0
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local max = #target:getCardIds { Player.Hand, Player.Equip }
        local cids = room:askForDiscard(player, 1, max, true, self.name, true, ".", "#mcdh_liniaoyunyi-invoke")
            if #cids > 0 then
                self.cost_data = cids
                return true
            end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:addPlayerMark(player, "@mcdh_liniaoyunyi-turn", #self.cost_data)
    end
})

liniaoyunyi:addEffect( fk.TurnEnd,{
    can_trigger = function(self, event, target, player, data)
        if event == fk.TargetConfirmed then
            return player:hasSkill(self) and target == player and #player:getCardIds("he") > 0
        end
        return player:hasSkill(self) and player:getMark("@mcdh_liniaoyunyi-turn") > 0
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        return player:getMark("@mcdh_liniaoyunyi-turn") > 0
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:drawCards(player, player:getMark("@mcdh_liniaoyunyi-turn"), self.name)

    end
})

Fk:loadTranslationTable{
    ["mcdh_liniaoyunyi"] = "翼陨",
    [":mcdh_liniaoyunyi"] = "『立鸟陨翼』<br>当你成为牌的目标后，你可以弃置任意张牌；每回合结束时，你摸X张牌（X为本回合你以此法弃置的牌数）。",
    ["#mcdh_liniaoyunyi-invoke"] = "立鸟陨翼:弃置任意张牌，本回合结束时摸等量张牌",
    ["@mcdh_liniaoyunyi-turn"] = "立鸟陨翼",
}
return liniaoyunyi